const state = {
  lng: '',
  lat: '',
  country: '',
  province: '',
  city: '',
  region: ''
}

const mutations = {
  GET_LOCATION: (state, data) => {
    state.lng = data.lon
    state.lat = data.lat
    state.country = data.country
    state.province = data.adm1
    state.city = data.adm2
    state.region = data.name
  }
}

const actions = {
  getLocation({ commit }, data) {
    commit('GET_LOCATION', data)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
